from wtforms import StringField, SubmitField, validators, PasswordField, BooleanField, SelectField, DateTimeField
from flask_wtf import FlaskForm
from wtforms.ext.sqlalchemy.fields import QuerySelectField
from .model.models import CommonCode
from app_db import db
from config import config


# 注册form
class RegisterForm(FlaskForm):
    name = StringField('用户名', validators=[validators.DataRequired(message='长度为2-50'),
                                          validators.Length(min=2, max=50)])
    password = PasswordField('密码', validators=[validators.DataRequired(message='请输入密码')])

    submit = SubmitField('立即注册')


# 登陆form
class LoginForm(FlaskForm):
    name = StringField('用户名', validators=[validators.DataRequired(message='长度为2-50'),
                                          validators.Length(min=2, max=50)])
    password = PasswordField('密码', validators=[validators.DataRequired(message='请输入密码')])
    remember_me = BooleanField('记住我')

    submit = SubmitField('登陆')


# 记账
class AccountForm(FlaskForm):
    date = DateTimeField('日期', validators=[validators.DataRequired()])
    money = StringField('金额', validators=[validators.DataRequired()])
    #income_expense_id = StringField('收支类别id', validators=[validators.DataRequired(message='数字')])

    income_expense_class_id = SelectField('收支一级类别', validators=[validators.DataRequired()])
    income_expense_id = SelectField('收支二级类别', validators=[validators.DataRequired()])

    income_expense_type_id = StringField('收支类型', validators=[validators.DataRequired(message='数字'),
                                                             validators.Length(min=1, max=2)])
    # account_id = StringField('账户id', validators=[validators.DataRequired(message='数字')])
    account_class_id = SelectField('账户一级类别', validators=[validators.DataRequired()])
    account_id = SelectField('账户一级类别', validators=[validators.DataRequired()])

    remark = StringField('备注', validators=[validators.DataRequired(message='长度为2-50'),
                                          validators.Length(min=2, max=500)])

    submit = SubmitField('提交')
